package com.manong.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manong.dao.NoticeMapper;
import com.manong.dao.OrderMapper;
import com.manong.entity.Notice;
import com.manong.entity.Order;
import com.manong.service.NoticeService;
import com.manong.service.OrderService;
import com.manong.vo.query.OrderVo;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
    /**
     * 分页查询订单列表
     * @param page
     * @param orderVo
     * @return
     */
    @Override
    public IPage<Order> findOrderListByUsername(IPage<Order> page, OrderVo orderVo) {
        QueryWrapper<Order> queryWrapper = new QueryWrapper<Order>();
        queryWrapper.like(!ObjectUtils.isEmpty(orderVo.getName()),"name",orderVo.getName())
                .eq(!ObjectUtils.isEmpty(orderVo.getStatus()),"status",orderVo.getStatus());
        return baseMapper.selectPage(page,queryWrapper);
    }

    @Override
    public boolean deleteById(Long id) {
        return baseMapper.deleteById(id)>0;
    }
}
